﻿using System;
using System.ComponentModel;
using System.Xml.Serialization;

namespace Interscape.TwilioClient.Components
{

    /// <summary>
    /// A paged collection of <see cref="Notification">Notification</see> objects.
    /// </summary>
    [Serializable]
    [XmlRoot("Notifications")]
    public class NotificationList : PagedList<Notification>
    {
    }

    /// <summary>
    /// A Notification represenents a log entry made by Twilio in the course of handling your calls or using the REST API. It is very useful for debugging purposes. 
    /// </summary>
    [Serializable]
    public class Notification : BaseAccountInfo
    {

        #region Constructors

        /// <summary>
        /// Creates a new instance of the Notification object.
        /// </summary>
        public Notification() : base()
        {
        }

        /// <summary>
        /// Creates a new instance of the Notification object.
        /// </summary>
        /// <param name="sid">A 34 character string that uniquely identifies this resource.</param>
        public Notification(string sid) : base(sid)
        {
        }

        #endregion

        /// <summary>
        /// CallSid is the unique id of the call during which the notification was generated. Empty if the notification was generated by the REST API without regard to a specific phone call. 
        /// </summary>
        [XmlElement]
        public string CallSid { get; set; }

        /// <summary>
        /// An integer log level corresponding to the type of notification: 0: ERROR, 1: WARNING
        /// </summary>
        [XmlElement]
        public int Log { get; set; }

        /// <summary>
        /// A unique error code for the error condition. You can lookup errors, with possible causes and solutions, in our Error Dictionary. 
        /// </summary>
        [XmlElement]
        [DefaultValue(0)]
        public Int32 ErrorCode { get; set; }

        /// <summary>
        /// A URL for more information about the error condition. The URL is a page in our Error Dictionary. 
        /// </summary>
        [XmlElement]
        public string MoreInfo { get; set; }

        /// <summary>
        /// The text of the notification. 
        /// </summary>
        [XmlElement]
        public string MessageText { get; set; }

        /// <summary>
        /// The date the notification was actually generated, given in RFC 2822 format. Due to buffering, this may be slightly different than the DateCreated date. 
        /// </summary>
        [XmlElement]
        public string MessageDate { get; set; }

        /// <summary>
        /// The HTTP method in use for the request that generated the notification.
        /// </summary>
        /// <remarks>
        /// <para>If the notification was generated during a phone call: The HTTP Method use to request the resource on your server. Either GET or POST.</para>
        ///<para>If the notification was generated by your use of the REST API: This is the HTTP method used in your request to the REST resource on Twilio's servers. One of GET, POST, PUT or DELETE.</para>
        /// </remarks>
        [XmlElement]
        public string RequestUrl { get; set; }

        /// <summary>
        /// The URL of the resource that generated the notification. 
        /// </summary>
        /// <remarks>
        /// <para>If the notification was generated during a phone call: This is the URL of the resource on YOUR SERVER that caused the notification.</para>
        ///<para>If the notification was generated by your use of the REST API: This is the URL of the REST resource you were attempting to request on Twilio's servers.</para>
        /// </remarks>
        [XmlElement]
        public string Method { get; set; }

        /// <summary>
        /// The Twilio-generated HTTP GET or POST variables sent to your server. Alternatively, if the notification was generated by the REST API, this field will include any HTTP POST or PUT variables you sent to the REST API
        /// </summary>
        [XmlElement]
        public string RequestVariables { get; set; }

        /// <summary>
        /// The HTTP headers returned by your server.
        /// </summary>
        [XmlElement]
        public string ResponseHeaders { get; set; }

        /// <summary>
        /// The HTTP body returned by your server.
        /// </summary>
        [XmlElement]
        public string ResponseBody { get; set; }


    }
}
